<html>
<head><meta charset="utf-8"><title>global_asm not included · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/global_asm.20not.20included.html">global_asm not included</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209003807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/global_asm%20not%20included/near/209003807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/global_asm.20not.20included.html#209003807">(Sep 03 2020 at 17:37)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">extern</span><span class="w"> </span><span class="s">&quot;C&quot;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">__yk_swt_rec_loc</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[no_mangle]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="k">fn</span> <span class="nf">_yk_a</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">__yk_swt_rec_loc</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="n">global_asm</span><span class="o">!</span><span class="p">(</span><span class="w"></span>
<span class="w">    </span><span class="n">r</span><span class="err">#</span><span class="s">&quot;</span>
<span class="s">.globl __yk_swt_rec_loc</span>
<span class="s">.type __yk_swt_rec_loc,@function</span>
<span class="s">.section .text.__yk_swt_rec_loc,&quot;</span><span class="n">ax</span><span class="s">&quot;,@progbits</span>
<span class="s">__yk_swt_rec_loc:</span>
<span class="s">    retq</span>
<span class="s">&quot;</span><span class="err">#</span><span class="w"></span>
<span class="p">);</span><span class="w"></span>
</code></pre></div>


<p>When literally used as source works fine. However in a certain project the <code>__yk_swt_rec_loc</code> symbol from the <code>global_asm!</code> is omitted resulting in a linker error. Any idea what could cause this.</p>



<a name="209005752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/global_asm%20not%20included/near/209005752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/global_asm.20not.20included.html#209005752">(Sep 03 2020 at 17:52)</a>:</h4>
<p>(what are you using yorick for btw ?)</p>



<a name="209005832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/global_asm%20not%20included/near/209005832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/global_asm.20not.20included.html#209005832">(Sep 03 2020 at 17:53)</a>:</h4>
<p>I am trying if I can integrate it with cg_clif.</p>



<a name="209006060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/global_asm%20not%20included/near/209006060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/global_asm.20not.20included.html#209006060">(Sep 03 2020 at 17:55)</a>:</h4>
<p>nice, sounds interesting</p>



<a name="209011208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/global_asm%20not%20included/near/209011208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/global_asm.20not.20included.html#209011208">(Sep 03 2020 at 18:36)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> Does it work if you put it directly in <code>.text</code> instead of a separate section just for that function?</p>



<a name="209014774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/global_asm%20not%20included/near/209014774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/global_asm.20not.20included.html#209014774">(Sep 03 2020 at 19:04)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> That doesn't help.</p>



<a name="209064819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/global_asm%20not%20included/near/209064819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/global_asm.20not.20included.html#209064819">(Sep 04 2020 at 07:53)</a>:</h4>
<p>The <code>global_asm!</code> is missing from the llvm bitcode already.</p>



<a name="209067652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/global_asm%20not%20included/near/209067652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/global_asm.20not.20included.html#209067652">(Sep 04 2020 at 08:32)</a>:</h4>
<p>The problem seems to be somewhere in ykrustc when <code>-Ctracer=hw</code> is used.</p>



<a name="209070511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/global_asm%20not%20included/near/209070511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/global_asm.20not.20included.html#209070511">(Sep 04 2020 at 09:09)</a>:</h4>
<p>Found the problem. Ykrustc was replacing global asm instead of appending it somewhere.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>